package grouplife::Model::UserTuanStores::UserTuanStoresModel;

use base 'Catalyst::Model';
use Util::UserTuanStores::UserTuanStores;
use Moose;

our $AUTOLOAD;

has 'UserTuanStoresInstance' => (
  is => 'rw',
  isa => 'Util::UserTuanStores::UserTuanStores',
);

sub initialize_after_setup {
  my ( $self, $app ) = @_;
  $app->log->info('Initializing UserTuanStores with schema AFTER app is fully loaded...');
  $self->UserTuanStoresInstance(
    Util::UserTuanStores::UserTuanStores->new( schema => $app->model('DB')->schema )
  );
}

# Here you would map your Catalyst Model methods to the actual model
# in this example we will just forward everything as is to our
# UsearsSearch external Model

sub AUTOLOAD {
  my $self = shift;
  my $name = $AUTOLOAD;
  $name =~ s/.*://;
  $self->UserTuanStoresInstance->$name(@_);
}

__PACKAGE__->meta->make_immutable;
1;
